<template>
  <div>
       <div style="margin-left:500px;width:200px">
      <h1>登录页面</h1>
     
        用户名：<div><el-input type="text" v-model="userBean.userName"  placeholder="请输入用户名"></el-input></div><br>
        密码：<div><el-input type="passwork" show-password v-model="userBean.pwd" placeholder="请输入密码"></el-input></div><br>
        <div style="display:flex">
          <div> <el-button type="success"  @click="login">登录</el-button></div>
          

        </div>
         
         
          
      </div>
  </div>
</template>

<script>
import ajax from "../service/ajax.js"
import {mapState,mapActions,mapMutations} from "vuex"
export default {
    computed:{
        ...mapState("login",["user"]),
    },
    data(){
        return{
            userBean:{}
        }
    },
     methods:{
       ...mapMutations("login",["setUser"]),
    
        async login(){
          //  alert(JSON.stringify(this.userBean))
           var info = await ajax.getSubmit("/api/users/login",this.userBean)
          
          if(info.length == 0){
                alert("登录失败")
            }
            else{             
              this.setUser(info)
            alert("登录成功")
           this.$router.push("/reply");
            }
        }
    }

}

</script>

<style>

</style>